﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;

namespace Se.Net.Sockets
{
    public class BufferManager
    {
        private int _capacity;
        private byte[] _bufferBlock;
        private int _saeaSize;

        public void Init(int capacity, int saeaSize)
        {
            this._capacity = capacity;
            this._bufferBlock = new byte[capacity];
            this._saeaSize = saeaSize;
        }

        public void SetBuffer(List<SocketAsyncEventArgs> eventArgsList)
        {
            int currentIndex = 0;
            eventArgsList.ForEach(args =>
            {
                args.SetBuffer(this._bufferBlock, currentIndex, this._saeaSize);
                currentIndex += this._saeaSize;
            });
        }
    }
}
